import { Component } from 'react'

export default class App extends Component {
  // 和上面等价：往实例上面挂载了 state，注意：state 必须是一个对象
  state = {
    list: [
      { id: 1, name: '明天会更好' },
      { id: 2, name: '今天' },
    ],
  }
  render() {
    // this => 实例对象
    return (
      <ul>
        {this.state.list.map((item) => (
          <li key={item.id}>{item.name}</li>
        ))}
      </ul>
    )
  }
}
